
import React, { Component } from 'react';
import { observer, inject } from 'mobx-react';
import { withRouter } from 'react-router-dom';
import { Browser,  BrowserHrm, BrowserCity } from 'weaver-mobile-page';

@inject('edcTaskViewStore','browserAllBrowserStore')
@withRouter
@observer
export default class TaskPath extends Component {
  render() {
    const { history } = this.props;
    const { browserHrm, browserHrm1, setState, browserHrmValue,browserValue, browserHrmValue1 ,setValue, isSingle, type,
      browserCitygj,browserCitysf,browserCitycs,browserCityqx,browser,conditionURL, dataUrl, dataParamsObj,tabsArr } = this.props.browserAllBrowserStore;
    const {setissueOperators} = this.props.edcTaskViewStore;
    //this.handleChange(type);
    return (
      <div style={{display:"none"}}>
        <BrowserHrm
          label="人力单选"
          store={browserHrm}
          hasAdvanceSerach
          isSingle={isSingle}
          type={1}
          onChange={(...arg) => {
            console.log('BrowserHrm onchange: ',arg, ...arg);
            setValue(arg[2] );
          }}
          valueArray={browserValue}
        />
        <BrowserHrm
          label="人力多选"
          store={browserHrm1}
          hasAdvanceSerach
          isSingle={false}
          type={1}
          onChange={(...arg) => {
            console.log('BrowserHrm onchange: ',arg, ...arg);
            setissueOperators(arg[2] );
          }}
          valueArray={browserValue}
        />
        <BrowserCity label="国家" type={258} store={browserCitygj} valueArray ={browserValue} onChange={(id, name, data) => {
          console.log('国家', id, name, data);
          setValue(data );}} />
        <BrowserCity label="省份" type={2222} store={browserCitysf} valueArray={browserValue} onChange={(id, name, data) => {
          console.log('省份', id, name, data);
          setValue(data );
          }} />
          }} />
      
        <BrowserCity label="城市" type={58} store={browserCitycs} valueArray={browserValue} onChange={(id, name, data) => {
          console.log('城市', id, name, data);
          setValue(data );
          } }/>
      
        <BrowserCity label="区县" type={263} store={browserCityqx} valueArray={browserValue} onChange={(id, name, data) => {
          console.log('区县', id, name, data);
          setValue(data );
      }} />
        <Browser
          label={type}
          store={browser}
          hasAdvanceSerach
          isSingle={isSingle}
          dataParams={dataParamsObj}
          type={type}
          tabs={tabsArr}
          dataUrl={dataUrl}
          conditionURL={conditionURL}
          valueArray={browserValue}
          onChange={(...arg) => {
            console.log('Browser onchange: ',arg, ...arg);
            setValue(['164','4'].indexOf(type)>-1 ? [...arg] : arg[2] );
          }}
        />

      </div>
    );
  }

  handleChange = (key) => {
    const { browserAllBrowserStore } = this.props;
    browserAllBrowserStore.browser.setState({ valueArray: [] });
    browserAllBrowserStore.browserMutil.setState({ valueArray: [] });
    browserAllBrowserStore.setState({ type: key });
    let obj = '';
    switch (key) {
      case '22':
      case '222':
      case '251':
        browserAllBrowserStore.setState({ dataParams: '', tabs: '[{"dataParams": {"qryType": "1"}, "isSearch": true, "key": "1", "name": "最近", "selected": false, "showOrder": 0},{"isSearch": false, "key": "2", "name": "按科目结构", "selected": false, "showOrder": 0}]' });
        break;
      case '160':
        //browserAllBrowserStore.setState({ dataParams: '{ "roleid": 251 }', tabs: '' });
        break;
      case '161':
        //browserAllBrowserStore.setState({ dataParams: '{ "type": "browser.llkwj02", "formmodefieldid": "38865" }', tabs: '' });
        break;
      case '162':
        //browserAllBrowserStore.setState({ dataParams: '{ "type": "browser.llkwj02", "formmodefieldid": "38865" }', tabs: '' });
        break;
      case '4':
      case '57':
      case '164':
      case '165':
      case '166':
      case '167':
      case '168':
      case '169':
      case '170':
      case '194':
        browserAllBrowserStore.setState({ dataParams: '', tabs: '[{"isSearch":false,"key":"2","name":"组织结构","selected":false,"showOrder":0},{"dataParams":{"list":"1"},"isSearch":true,"key":"1","name":"按列表","selected":false,"showOrder":0}]' });
        break;
      case '226':
        //obj = `${key} + '?wfid=1328&billid=-1919&isbill=1&requestid=-1&f_weaver_belongto_userid=1&f_weaver_belongto_usertype=0&fieldid=37466&viewtype=0&wfCreater=1&fielddbtype=browser.17&rowIndex=-1&field37459=&min=1&max=10&pageSize=10&issearch=true'`;
        //browserAllBrowserStore.setState({ dataParams: obj, tabs: '' });
        break;
      case '227':
        //obj = `${key} + '?wfid=1328&billid=-1919&isbill=1&requestid=-1&f_weaver_belongto_userid=1&f_weaver_belongto_usertype=0&fieldid=37466&viewtype=0&wfCreater=1&fielddbtype=browser.17&rowIndex=-1&field37459=&min=1&max=10&pageSize=10&issearch=true'`;
        //browserAllBrowserStore.setState({ dataParams: obj, tabs: '' });
        break;
      case '256':
        //browserAllBrowserStore.setState({ dataParams: '{ "treeid": 5, "treetype": 257, "checkStrictly": false, "type": 5, "wfid": 1470, "billid": -2201, "isbill": 1, "requestid": -1, "f_weaver_belongto_userid": 1, "f_weaver_belongto_usertype": 0, "fieldid": 44090, "viewtype": 0, "wfCreater": 1, "min": 1, "max": 10, "pageSize": 10 }', tabs: '' });
        break;
      case '257':
        //browserAllBrowserStore.setState({ dataParams: '{ "treeid": 5, "treetype": 257, "checkStrictly": false, "type": 5, "wfid": 1470, "billid": -2201, "isbill": 1, "requestid": -1, "f_weaver_belongto_userid": 1, "f_weaver_belongto_usertype": 0, "fieldid": 44090, "viewtype": 0, "wfCreater": 1, "min": 1, "max": 10, "pageSize": 10 }', tabs: '' });
        break;
      case '274':
        //browserAllBrowserStore.setState({ dataParams: '{ "CustomerID": [0, 215, 69, 209, 161, 158, 189, 212, 172, 106, 63, 190, 173, 216, 210, 170, 61, 196, 211, 188, 205, 5, 159, 160, 214, 68, 157] }', tabs: '' });
        break;
      default:
        //browserAllBrowserStore.setState({ dataParams: '', tabs: '' });
        break;
    }
  }
}